package ualrcdg.shared.dto;

import ualrcdg.shared.exceptions.CDGTypeException;

/**
 * Simple implementation of the "chunkMedia" object. See CDG XML Specifications: Game Descriptor Files.
 */
public class ChunkMedia extends Media
{
	/**
	 * Tag class for CDG chunkMedia types.
	 */
	static enum ChunkType { text, haptic };
	
	private final ChunkType type;
	private final String tagId;

	/**
	 * Primary constructor
	 *
	 * @param type the type of the ChunkMedia object to be created
	 * @param tagId the tagId of the ChunkMedia object to be created
	 * @throws CDGTypeException If the type specified is not valid
	 */
	public ChunkMedia( String id, String name, String type, String tagId ) throws CDGTypeException
	{
		super( id, name );
		try
		{
			this.type = ChunkType.valueOf( type );
		}
		catch( IllegalArgumentException e )
		{
			throw new CDGTypeException( "The type: " + type + " is not a valid ChunkType type." );
		}
		this.tagId = tagId;
		
		System.out.println( "Parsed: " + this.toString( ) );
	}

	/*
	 * @see ualrcdg.shared.dto.Media#toString()
	 */
	@Override
	public String toString( )
	{
		return "ChunkMedia [<" + super.toString( ) + "> tagId=" + tagId + ", type=" + type + "]";
	}

	/**
	 * @return the type of this ChunkMedia instance
	 */
	public ChunkType getType( )
	{
		return type;
	}

	/**
	 * @return the tagId of this ChunkMedia instance
	 */
	public String getTagId( )
	{
		return tagId;
	}
}
